Uec3.PresentPackageWindow = Ext.extend(Ext.app.Module,{
	id: 'presentPackage',
   /*
    * Initialize this module.
    * This function is called at startup (page load/refresh).
    */
   init : function(initParams){
   
   },
 
   getComponent:function(params){
   	   
   	    var companyId = params.companyId;    
   		var companyName=params.companyName;
   		var form = new Ext.FormPanel({
   			border:false,
   			frame:true,
   			labelAlign:'left',
   			labelWidth:60,
   			buttonAlign:'center',
   			autoHeight:true,
   			items:[
   			   {
   			     xtype:'hidden',
   			     name:'companyId',
   			     value:companyId
   			   },{
   			     xtype:'textfield',
   			     fieldLabel:'公司',
   			     name:'companyName',
   			     value:companyName,
   			     allowNegative:false,
   			     allowBlank :false,
   			     anchor:'100%'
   			   },{
            	 xtype: 'compositefield',
            	 fieldLabel: '赠送金额',
           	     combineErrors: false,
           	     items: [
	                {xtype: 'numberfield',    name: 'sum', width: 100, allowBlank: false},
	                {xtype: 'displayfield', value: '个U币'}
            	]
        		},{
   			     xtype:'textarea',
   			     fieldLabel:'说明',
   			     name:'description',
   			     allowNegative:false,
   			     allowBlank :false,
   			     anchor:'100%'
   			   }
   			],
   			buttons:[
   			  {text:'确定',handler:presentPackage},
   			  {text:'取消',handler:function(){
   			  					form.ownerCt.close();
   			  			}
   			  }
   			]
   		});
   		
   		function presentPackage(){
   		   if(!form.getForm().isValid()){
   		   		return;
   		   }else{  		      
   		      Ext.MessageBox.confirm("提示","确定赠送?",function(btnId){
   		      		if(btnId == 'yes'){
   		      			var myMask = new Ext.LoadMask(form.ownerCt.el,{msg : "正在操作中,请稍后....." });
                        myMask.show(); 
                        var queryParam = Ext.encode(form.getForm().getValues());
                        Ext.Ajax.request({		            
				      		url:Uec3.App.Constants.homeUrl+"/company/presentPackage.do",
				      		method :"post",					   
				      		params:{queryParam:queryParam},				      		
				      		callback :function(options,success,response){                				
                      		},
                      		success:function(response,options){                     			
                      	 		var resp = Ext.decode(response.responseText);                     	 		
				         		Ext.Msg.alert("提示",resp.msg);
				         		myMask.hide();				         		
                      		},
                      		failure:function(response,options){
                         		Ext.Msg.alert("提示","网络连接异常,稍后再试!");
                         		myMask.hide();
                      		}
		      			}); 
   		      			
   		      		}
   		      });
   		   }
   		}
   		return form;
   },
   
   /**
	* Create this modules window here.
	*/
   createWindow : function(params){
    	var desktop = this.app.getDesktop();
        var win = desktop.getWindow('presentPackageWindow');
        if (!win) {
			win = desktop.createWindow({
				        id : "presentPackageWindow",
						title : '赠送U币',
						width : 300,
						autoHeight : true,
						iconCls : 'acc-icon',
					    minWidth:300,
						maximizable : false,
						//maximized:true,
						//autoScroll : true,
						constrainHeader : true,
						taskbuttonTooltip : "赠送U币",
						//layout : "fit",
						items : [this.getComponent(params)]
					});
		}
		//win.get(0).get(1).setHeight(win.getHeight()-70);
    	win.show(); 
       /* win.on('resize',function(win,width,height){
      	   win.get(0).get(1).setHeight(height-72);
        });*/
   }
});